#ifndef ENGINE_CLOCK3_H
#define ENGINE_CLOCK3_H

#include <windows.h>

namespace Shiny
{
	namespace Timing
	{
		class __declspec(dllexport) Clock
		{
		private:
			LARGE_INTEGER timeLastFrame;
			LARGE_INTEGER timeFrequency;
			LARGE_INTEGER deltaLastFrame;

			float deltaTime;

		public:
			bool Initialise()
			{
				if (!QueryPerformanceFrequency(&timeFrequency))
					return false; // Couldn't query performance frequency

				if (!QueryPerformanceCounter(&timeLastFrame))
					return false; // Couldn't query performance counter

				return true;
			}

			bool Shutdown()
			{
				return true;
			}


			void Update()
			{
				// Retrieve the current frame time
				LARGE_INTEGER currentFrameTime;
				QueryPerformanceCounter(&currentFrameTime);

				// Calculate the difference since the last frame time
				LARGE_INTEGER deltaSinceLast;
				deltaSinceLast.QuadPart = currentFrameTime.QuadPart - timeLastFrame.QuadPart;
				deltaTime = ((float)deltaSinceLast.QuadPart) / timeFrequency.QuadPart;

				timeLastFrame.QuadPart = currentFrameTime.QuadPart;

			}

			float GetTimeElapsed() const
			{
				return deltaTime;
			}
		
		
		
		
		
		
		};
	}
}

#endif